home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / netinclude / rpc / rpc_msg.h < prev    next >
C/C++ Source or Header  |  1994-03-09  |  4KB  |  187 lines

  1. /*
  2.  * $Id: rpc_msg.h,v 1.2 1993/11/10 00:52:21 jraja Exp $
  3.  *
  4.  * $Log: rpc_msg.h,v $
  5.  * Revision 1.2  1993/11/10  00:52:21  jraja
  6.  * ANSI prototypes.
  7.  * Added protoypes for xdr_accepted_reply() and xdr_rejected_reply().
  8.  *
  9.  */
  10. /* @(#)rpc_msg.h    2.1 88/07/29 4.0 RPCSRC */
  11. /*
  12.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  13.  * unrestricted use provided that this legend is included on all tape
  14.  * media and as a part of the software program in whole or part.  Users
  15.  * may copy or modify Sun RPC without charge, but are not authorized
  16.  * to license or distribute it to anyone else except as part of a product or
  17.  * program developed by the user.
  18.  * 
  19.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  20.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  21.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  22.  * 
  23.  * Sun RPC is provided with no support and without any obligation on the
  24.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  25.  * modification or enhancement.
  26.  * 
  27.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  28.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  29.  * OR ANY PART THEREOF.
  30.  * 
  31.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  32.  * or profits or other special, indirect and consequential damages, even if
  33.  * Sun has been advised of the possibility of such damages.
  34.  * 
  35.  * Sun Microsystems, Inc.
  36.  * 2550 Garcia Avenue
  37.  * Mountain View, California  94043
  38.  */
  39. /*      @(#)rpc_msg.h 1.7 86/07/16 SMI      */
  40.  
  41. /*
  42.  * rpc_msg.h
  43.  * rpc message definition
  44.  *
  45.  * Copyright (C) 1984, Sun Microsystems, Inc.
  46.  */
  47.  
  48. #define RPC_MSG_VERSION        ((u_long) 2)
  49. #define RPC_SERVICE_PORT    ((u_short) 2048)
  50.  
  51. /*
  52.  * Bottom up definition of an rpc message.
  53.  * NOTE: call and reply use the same overall stuct but
  54.  * different parts of unions within it.
  55.  */
  56.  
  57. enum msg_type {
  58.     CALL=0,
  59.     REPLY=1
  60. };
  61.  
  62. enum reply_stat {
  63.     MSG_ACCEPTED=0,
  64.     MSG_DENIED=1
  65. };
  66.  
  67. enum accept_stat {
  68.     SUCCESS=0,
  69.     PROG_UNAVAIL=1,
  70.     PROG_MISMATCH=2,
  71.     PROC_UNAVAIL=3,
  72.     GARBAGE_ARGS=4,
  73.     SYSTEM_ERR=5
  74. };
  75.  
  76. enum reject_stat {
  77.     RPC_MISMATCH=0,
  78.     AUTH_ERROR=1
  79. };
  80.  
  81. /*
  82.  * Reply part of an rpc exchange
  83.  */
  84.  
  85. /*
  86.  * Reply to an rpc request that was accepted by the server.
  87.  * Note: there could be an error even though the request was
  88.  * accepted.
  89.  */
  90. struct accepted_reply {
  91.     struct opaque_auth    ar_verf;
  92.     enum accept_stat    ar_stat;
  93.     union {
  94.         struct {
  95.             u_long    low;
  96.             u_long    high;
  97.         } AR_versions;
  98.         struct {
  99.             caddr_t    where;
  100.             xdrproc_t proc;
  101.         } AR_results;
  102.         /* and many other null cases */
  103.     } ru;
  104. #define    ar_results    ru.AR_results
  105. #define    ar_vers        ru.AR_versions
  106. };
  107. extern bool_t XDRFUN xdr_accepted_reply(XDR * xdrs, struct accepted_reply * ar);
  108.  
  109. /*
  110.  * Reply to an rpc request that was rejected by the server.
  111.  */
  112. struct rejected_reply {
  113.     enum reject_stat rj_stat;
  114.     union {
  115.         struct {
  116.             u_long low;
  117.             u_long high;
  118.         } RJ_versions;
  119.         enum auth_stat RJ_why;  /* why authentication did not work */
  120.     } ru;
  121. #define    rj_vers    ru.RJ_versions
  122. #define    rj_why    ru.RJ_why
  123. };
  124. extern bool_t XDRFUN xdr_rejected_reply(XDR * xdrs, struct rejected_reply * rr);
  125.  
  126. /*
  127.  * Body of a reply to an rpc request.
  128.  */
  129. struct reply_body {
  130.     enum reply_stat rp_stat;
  131.     union {
  132.         struct accepted_reply RP_ar;
  133.         struct rejected_reply RP_dr;
  134.     } ru;
  135. #define    rp_acpt    ru.RP_ar
  136. #define    rp_rjct    ru.RP_dr
  137. };
  138.  
  139. /*
  140.  * Body of an rpc request call.
  141.  */
  142. struct call_body {
  143.     u_long cb_rpcvers;    /* must be equal to two */
  144.     u_long cb_prog;
  145.     u_long cb_vers;
  146.     u_long cb_proc;
  147.     struct opaque_auth cb_cred;
  148.     struct opaque_auth cb_verf; /* protocol specific - provided by client */
  149. };
  150.  
  151. /*
  152.  * The rpc message
  153.  */
  154. struct rpc_msg {
  155.     u_long            rm_xid;
  156.     enum msg_type        rm_direction;
  157.     union {
  158.         struct call_body RM_cmb;
  159.         struct reply_body RM_rmb;
  160.     } ru;
  161. #define    rm_call        ru.RM_cmb
  162. #define    rm_reply    ru.RM_rmb
  163. };
  164. #define    acpted_rply    ru.RM_rmb.ru.RP_ar
  165. #define    rjcted_rply    ru.RM_rmb.ru.RP_dr
  166.  
  167.  
  168. /*
  169.  * XDR routine to handle a rpc message.
  170.  */
  171. extern bool_t XDRFUN    xdr_callmsg(XDR * xdrs, struct rpc_msg * cmsg);
  172.  
  173. /*
  174.  * XDR routine to pre-serialize the static part of a rpc message.
  175.  */
  176. extern bool_t XDRFUN    xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg);
  177.  
  178. /*
  179.  * XDR routine to handle a rpc reply.
  180.  */
  181. extern bool_t XDRFUN    xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg);
  182.  
  183. /*
  184.  * Fills in the error part of a reply message.
  185.  */
  186. extern void    _seterr_reply(struct rpc_msg *msg, struct rpc_err *error);
  187.